/*
* Accord Software, Inc.
*
* Tutorial 08
*
* Send a mesh, which is a doubly linked list in two
* directions, to be "printed" at the server. The
* server returns the sum of the numbers in the
* nodes.
*/
#include "mesh.h"
static struct mnode m[] = {
/*
* num up right down left
*/
{ 0, 0 , &m[ 1], &m[ 4], 0 },
{ 1, 0 , &m[ 2], &m[ 5], &m[ 0]},
{ 2, 0 , &m[ 3], &m[ 6], &m[ 1]},
{ 3, 0 , 0 , &m[ 7], &m[ 2]},
{ 4, &m[ 0], &m[ 5], &m[ 8], 0 },
{ 5, &m[ 1], &m[ 6], &m[ 9], &m[ 4]},
{ 6, &m[ 2], &m[ 7], &m[10], &m[ 5]},
{ 7, &m[ 3], 0 , &m[11], &m[ 6]},
{ 8, &m[ 4], &m[ 9], &m[12], 0 },
{ 9, &m[ 5], &m[10], &m[13], &m[ 8]},
{10, &m[ 6], &m[11], &m[14], &m[ 9]},
{11, &m[ 7], 0 , &m[15], &m[10]},
{12, &m[ 8], &m[13], 0 , 0 },
{13, &m[ 9], &m[14], 0 , &m[12]},
{14, &m[10], &m[15], 0 , &m[13]},
{15, &m[11], 0 , 0 , &m[14]},
};
main(argc, argv)
int argc;
char *argv[];
{
int sum = 0;
int j;
struct mnode *mp;
int msize = sizeof(m)/sizeof(struct mnode);
char *progname = argv[0];
for (j = 0; j < msize; j++)
sum += j;
/*
* Point to upper left node and call meshprint
*/
mp = &m[0];
printf("%s sum = %d\n", progname, meshprint(mp));
/*
* Point to lower right node and call meshprint
*/
mp = &m[msize-1];
printf("%s sum = %d\n", progname, meshprint(mp));
exit(0);
}